﻿<%namespace YouHP.Model%>
<%namespace YouHP.Utility%>
<%template _header%>
<script language="javascript" src="/support/editor/script_common.js"></script>
<script language="javascript" src="/support/editor/editor_function.js"></script>
<script type="text/javascript">
function OnEnter(field){ if( field.value == field.defaultValue ) { field.value = "";field.style.color="#333";} }
function OnExit(field){ if( field.value == "" ) { field.value = field.defaultValue;field.style.color="#aaa";}}
</script>
<div class="layout-cols2">
	<%template _memmenu%>
	<div class="pannelcontent">

		<div class="pcontent">
		<div class="panneldetail">
			<div class="panneltabs">

					 <a href="{this.GetUrl("/User/NewLogCommentList.aspx")}"
					  <%if {PageName}=="newlogcommentlist.aspx"%>
					  class="current"
					  <%/if%>>日志评论</a>

					 <a href="{this.GetUrl("/User/LogList.aspx")}"
					  <%if {PageName}=="loglist.aspx"%>
					  class="current"
					  <%/if%>>日志列表</a>
					  
					   <a href="{this.GetUrl("/User/LogAdd.aspx")}"
					  <%if {PageName}=="logadd.aspx"%>
					  class="current"
					  <%/if%>>写新日志</a>
	
				</div>	
   <div class="pannelbody">
	
 <%csharp%>if( IsPost){ <%/csharp%>
	    
	    <%template _MsgBox%>
	    
	    <%csharp%> } else { <%/csharp%>
	    

	        <div class="content">
	            <br />
	            <form id="topicform" name="topicform" method="post" action="">
	             <table class="editboxstyle">
	               
	                <tbody>
	                <tr>
                        <td>标题：</td>
	                    <td>
	                        <input type="text" name="ttitle" size="60" class="inputstyle" onChange="relatekwtitle();"/>
	                        &nbsp;&nbsp;<span>标题长度必须在{Config.TitleMinSize}-{Config.TitleMaxSize}之间</span>
	                    </td>
	                 </tr>
	                     
	                 <tr valign="top">
                         <td>内容：</td>
                         <td>
                            <textarea id="uchome-ttHtmlEditor" name="logbody" cols="90" rows="15" style="display:none"></textarea> 
                            <iframe src="/support/editor/editor.htm" name="uchome-ifrHtmlEditor" id="uchome-ifrHtmlEditor" scrolling="no" border="0" frameborder="0" style="width:600px;border: 1px solid #C5C5C5;" height="400"></iframe>
                            <!--<input type="button" id="issuance" onclick="javascript:edit_save();" value="保存发布" class="submit" />-->    
                            <br />                          
                            <p>内容长度必须在{Config.TopicMinSize}-{Config.TopicMaxSize}之间</p>
	                     </td>
    	            </tr>
    	            <tr>
					     <td>标签：</td>
					     <td><input type="text" name="tags" id="tags" value="" style="margin-bottom:-1px;" size="55" />&nbsp;<input type="button" onclick="relatekwbody();" value="自动获取"/>  (用空格隔开多个标签)</td>
    	            </tr>
    	            <tr>
    	                <td>&nbsp;</td>
    	                <td align="right"> 
	                           <span onmouseout="this.className='new_sbt'" onmouseover="this.className='new_sbt_h'"
                                    onclick="javascript:edit_save();CheckForm();" class="new_sbt">提交</span>
                           
                        </td>
    	            </tr>   
	                </tbody>
	                </table>             
	            </form>
	            <script type="text/javascript">
	                function CheckForm()
	                {
	                    _$('topicform').submit();
	                }
	                function createXMLHttp() {
                        if(window.XMLHttpRequest){
                            return new XMLHttpRequest();
                        } else if(window.ActiveXObject){
                            return new ActiveXObject("Microsoft.XMLHTTP");
                        } 
                        throw new Error("XMLHttp object could be created.");
                    }
                    function _sendRequest(url,func,isxml,postdata)
                    {
                        var xhr=createXMLHttp();
                        if(!postdata)postdata=null;
                        xhr.open(postdata?"POST":"GET",url,true);
                        if (postdata)
                        {
                            xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                        }
                        if(func){
		                    xhr.onreadystatechange=function(){
			                    if(xhr.readyState==4){
				                    func(isxml&&xhr.responseXML?xhr.responseXML:xhr.responseText)
			                    }
		                    }
	                    }
                        if (postdata === true)
                        {
                            postdata = '';
                        }
                        xhr.send(postdata)
                    }
                    function encodeURL(a) {
                        return window.encodeURIComponent?encodeURIComponent(a):escape(a)
                    }
                    function relatekw(title, message) {
//                        if (typeof title=='undefined')
//                        {
//                            title = _$('ttitle').value;
//                        }
//                        if (typeof message=='undefined')
//                        {
//                            //edit_save();
//                            message = _$('uchome-ttHtmlEditor').value;
//                        }	
                        title = encodeURL(title);
                        message = message.replace(/&/ig, '', message);
                        message = encodeURL(message);
                        _sendRequest('/pages/alpha/ajax/AjaxPage.aspx?t=relatekw', relatedkw,true, 'titleenc=' + title + '&contentenc=' + message);
                    }
                    function relatekwtitle(title){
                        if(typeof title=='undefined')
                        {
                            title = _$('ttitle').value;
                        }
                        relatekw(title,'');
                    }
                    function relatekwbody(message){
                        if(typeof message=='undefined')
                        {
                            edit_save();
                            message = _$('uchome-ttHtmlEditor').value; 
                        }
                        relatekw('',message);
                    }
                    function relatedkw(obj) {
	                    if (obj == null || typeof(obj) != "object" || obj.firstChild == null)
	                    {
		                    return;
	                    }
	                    if (is_ie)
	                    {
		                    //evalscript(obj.text);
		                    _$('tags').value = obj.text + _$('tags').value;
		                    _$('tags').value = getTags();
	                    }
	                    else
	                    {
		                    evalscript(obj.firstChild.firstChild.nodeValue);
	                    }
                    }
                    var evalscripts = new Array();
                    function evalscript(s) {

	                    if(s.indexOf('<script') == -1) return s;

	                    var p = /<script[^\>]*src=\"([^\x00]+?)\"[^\>]*( reload=\"1\")?><\/script>/ig;

	                    var arr = new Array();

	                    while(arr = p.exec(s)) appendscript(arr[1], '', arr[2]);

	                    p = /<script[^\>]*( reload=\"1\")?>([^\x00]+?)<\/script>/ig;

	                    while(arr = p.exec(s)) appendscript('', arr[2], arr[1]);

	                    return s;

                    }

                    function appendscript(src, text, reload) {
	                    var id = hash(src + text);
	                    if(!reload && in_array(id, evalscripts)) return;

	                    if(reload && _$(id)) {

		                    _$(id).parentNode.removeChild(_$(id));

	                    }

	                    evalscripts.push(id);

	                    var scriptNode = document.createElement("script");

	                    scriptNode.type = "text/javascript";

	                    scriptNode.id = id;

	                    try {

		                    if(src) {

			                    scriptNode.src = src;

		                    } else if(text){

			                    scriptNode.text = text;

		                    }

		                    _$('append_parent').appendChild(scriptNode);

	                    } catch(e) {}

                    }

                    function hash(string, length) {

	                    var length = length ? length : 32;

	                    var start = 0;

	                    var i = 0;

	                    var result = '';

	                    filllen = length - string.length % length;

	                    for(i = 0; i < filllen; i++){

		                    string += "0";

	                    }

	                    while(start < string.length) {

		                    result = stringxor(result, string.substr(start, length));

		                    start += length;

	                    }

	                    return result;

                    }

                    function stringxor(s1, s2) {

	                    var s = '';

	                    var hash = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

	                    var max = Math.max(s1.length, s2.length);

	                    for(var i=0; i<max; i++) {

		                    var k = s1.charCodeAt(i) ^ s2.charCodeAt(i);

		                    s += hash.charAt(k % 52);

	                    }

	                    return s;
                    }
                    function getTags(){
                            var oldValue = new Array();
                            var newValue = new Array();
                            var newStr="";
                            var str = _$('tags').value;
                            if(str == "")
                            {
                               return newStr;
                            } 
                            oldValue=str.split(" "); 
                            if(oldValue.length<2)
                            {
                               return newStr; 
                            } 

                            for(t=0;t<oldValue.length;t++)
                            { 
                                if(!compare(oldValue[t],newValue))
                                { 
                                    newValue.push(oldValue[t]); 
                                    newStr += oldValue[t];
                                    newStr +=" ";
                                } 
                            } 
                            return newStr;
                        } 
                        /* 
                          方法：比对字符串是否存在于数组 
                          参数1：str 需要比对的字符串 
                          参数2：arrayValue 比对的数组 
                        */ 
                        function compare(str,arrayValue){ 
                        //数组为空 
                            if(arrayValue.length<0)
                            { 
                                return false; 
                            } 
                            //判断str是否存在于数组 
                            for(i=0;i<arrayValue.length;i++)
                            { 
                               if(str==arrayValue[i])
                               { 
                                  return true; 
                               } 
                            } 
                            return false; 
                        } 
	            </script>
	            <br />
	        </div>
	    
	    <%csharp%> } <%/csharp%>
		
	
</div>
</div>
</div>
</div>
</div>


<%template _footer%>